ExpandString

The ExpandString method expands a string by replacing any embedded environment variables, such as %SystemRoot%, with their corresponding values.

Syntax

ExpandString(String)

Parameters

String
A string that contains environment variables.

Return Value

An expanded string in which all environment variables have been replaced with their values.

Example

The following example retrieves the value LogFileDirectory from the registry key HKLM\System\CurrentControlSet\Services\W3SVC\Parameters\. The example uses the Get method to retrieve LogFileDirectory without expanding the environment variables and then uses the ExpandString method to expand the environment variables in the string.
<% 
Set Reg = Server.CreateObject("IISSample.Registry")
 
LFD = Reg.Get("HKLM\System\CurrentControlSet\Services\W3SVC\Parameters\LogFileDirectory") 
 
LFDEX = Reg.ExpandString(LFD) 
%>
LogFileDirectory = <%= LFD %><br>
LogFileDirectory Expanded = <%= LFDEX %>
 

If in the preceding example the environment variable %SystemRoot% has the value D:\Winnt and the value stored in LogFileDirectory is %SystemRoot%\System32\LogFiles\, the output would be:
LogFileDirectory = %SystemRoot%\System32\LogFiles\
LogFileDirectory Expanded = D:\Winnt\System32\LogFiles\
 

Note that the second line of the preceding output could also have been generated by calling the GetExpand method.

Applies To

Registry Access Component

See Also

Get, GetExpand, SetExpand, ValueType